package servlet;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspWriter;

import Model.Appointment;

/**
 * Servlet implementation class ApptFilterDropdown
 */
@WebServlet("/PendingApptFilterDropdown")
public class PendingApptFilterDropdown extends HttpServlet {
	private static final long serialVersionUID = 1L;
	JspWriter out;   
    /**
     * @see HttpServlet#HttpServlet()
     */
    public PendingApptFilterDropdown() {
        super();
        // TODO Auto-generated constructor stub
    }
    
    public PendingApptFilterDropdown(JspWriter outputStream) {
		// TODO Auto-generated constructor stub
		out = outputStream;
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		out.print("<option value=\"all\">All</option>");
		ArrayList<Appointment> appointmentList = new ArrayList<Appointment>();
		appointmentList = Database.AppointmentDB.getAllAppointments();
		
		for(int i = 0; i < appointmentList.size(); i++)
		{
			out.print("<option value='" + appointmentList.get(i).getId() + "'>");
				out.print(appointmentList.get(i).getName());
			out.print("</option>");
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
